var express = require('express');
var router = express.Router();
var formidable = require('formidable')
var fs = require('fs')

//返回图片
router.get('/', (req, res, next) => {
    let file_path = './workAnalysis/' + req.query.seq + '_' + req.query.type + 'Analysis.xlsx';
    console.log(file_path);
    fs.exists(file_path, exists => {
        if(exists) {
            console.log("开始下载！")
            res.download(file_path, err => {
                if(err) {
                    console.log(err);
                    res.json({'state': false, 'msg': err})
                }else {
                    console.log('success')
                }
            });
        }else {
            res.json({
                'state': false,
                'msg': '此文件不存在!'
            })
        }
    })
});

module.exports = router;